package java_zhuoer_adv3;

import java.lang.reflect.Constructor;

public class TestClass {

	public static void main(String[] args) throws Exception {
		Class c = Student.class;
		System.out.println("获得Student所有的构造方法");

		Constructor[] cr = c.getDeclaredConstructors();
		for (Constructor c1 : cr) {
			System.out.println(c1);
		}
		Constructor c2 = c.getDeclaredConstructor(String.class, String.class);
		// what am I doing?
		Student s = (Student) c2.newInstance("cn001", "孙成宇");
		System.out.println(s);
		// Class c2 = int.class;
		// try {
		// Student st = (Student) c.newInstance();
		// System.out.println(st);
		// } catch (InstantiationException e) {
		// // TODO 自动生成的 catch 块
		// e.printStackTrace();
		// } catch (IllegalAccessException e) {
		// // TODO 自动生成的 catch 块
		// e.printStackTrace();
		// }

	}

}
